package thread;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Hua YY
 * Date: 2024-09-29
 * Time: 18:38
 */
public class ThreadDemon37 {
    private static int sum = 0;//全局变量用来保存最后的结果值
    public static void main(String[] args) throws InterruptedException {

        Thread t1 = new Thread(new Runnable() {
            int count = 0;//局部变量
            @Override
            public void run() {
                for (int i = 1 ; i <= 5000 ; i++){
                    count += i;
                }
                sum = count;
            }
        });
        t1.start();
        t1.join();
        System.out.println(sum);
    }


}
